package org.niu.tree;

public class IsSymmetric {
    public boolean isSymmetric (TreeNode root) {
        // write code here
        if(root == null){
            return true;
        }
        return helper(root.left,root.right);
    }
    boolean helper(TreeNode a,TreeNode b){
        if(a==null&&b==null) return true;
        if(a==null || b==null) return false;
        if(a.val!=b.val) return false;
        return helper(a.left,a.right) && helper(a.right,b.left);
    }
}
